package org.peterf.foxish.texture;

import org.peterf.foxish.R;
import org.peterf.foxish.opengl20.OpenGLUtil;
import org.peterf.foxish.util.EngineException;

import android.graphics.Bitmap;

public class Texture {

    protected int height;

    protected int name;

    protected boolean shared = false;

    protected int width;

    /* package */Texture() {
    }

    /* package */Texture(Texture ref) {
        height = ref.height;
        name = ref.name;
        width = ref.width;
        shared = true;
    }

    public void delete() {
        if (!shared) {
            OpenGLUtil.deleteTexture(name);
        }
    }

    public int getHeight() {
        return height;
    }

    public int getWidth() {
        return width;
    }

    public void use() {
        OpenGLUtil.activeTexture();
        OpenGLUtil.bindTexture(name);
    }

    /* package */Texture shared() {
        return new Texture(this);
    }
    
    public SlicedTexture slice(int countX, int countY) {
        return new SlicedTexture(this, countX, countY);
    }
    
}
